package com.mt.checkerin.model;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.http.Header;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicHeader;
import org.apache.http.message.BasicNameValuePair;

public class PageForm {
	
	private String name;
	
	private String url;
	
	private Map<String, String> formFieldMap = new HashMap<String, String>();
	
	private List<Header> headerList = new ArrayList<Header>();
	
	private String method = "POST";
	
	private String responseBody;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public Map<String, String> getFormFieldMap() {
		return formFieldMap;
	}

	public void setFormFieldMap(Map<String, String> formFieldMap) {
		this.formFieldMap = formFieldMap;
	}

	public String getMethod() {
		return method;
	}

	public void setMethod(String method) {
		this.method = method;
	}
	
	public void addHeader(String key, String value) {
		headerList.add(new BasicHeader(key, value));
	}
	
	public List<NameValuePair> getFormNamePairs() {
		List<NameValuePair> formParams = new ArrayList<NameValuePair>();
		
		for (String name : getFormFieldMap().keySet()) {
			formParams.add(
					new BasicNameValuePair(name, 
							getFormFieldMap().get(name)
							));
		}
		return formParams;
	}

	public String getResponseBody() {
		return responseBody;
	}

	public void setResponseBody(String responseBody) {
		this.responseBody = responseBody;
	}

	public List<Header> getHeaderList() {
		return headerList;
	}
	
	public Header[] getHeaderArray() {
		return headerList.toArray(new Header[headerList.size()]);
	}

	public void addHeaderList(List<Header> headerList) {
		this.headerList.addAll(headerList);
	}
	
	
	
}
